function [F1, F11, F2] = C57_CPP_Cross_Day_PV_DeltaT(XDay_PV_Summary)
%% get cross-day PV vs deltaT for C5

T1(:,1) = (extractfield(XDay_PV_Summary.C57_5, 'Date1'))';
T1(:,2) = (extractfield(XDay_PV_Summary.C57_5, 'Date2'))';
T1 = datetime(T1,'InputFormat','yyyy-MM-dd');

for n = 1:size(T1,1)
    deltaT1(n,1) = daysact(T1(n,1),T1(n,2));
end

PV1 (:,1) = extractfield(XDay_PV_Summary.C57_5, 'Memory_Index');

%% get cross-day PV vs deltaT for C6

T2(:,1) = (extractfield(XDay_PV_Summary.C57_6, 'Date1'))';
T2(:,2) = (extractfield(XDay_PV_Summary.C57_6, 'Date2'))';
T2 = datetime(T2,'InputFormat','yyyy-MM-dd');

for n = 1:size(T2,1)
    deltaT2(n,1) = daysact(T2(n,1),T2(n,2));
end

PV2 (:,1) = extractfield(XDay_PV_Summary.C57_6, 'Memory_Index');

%% get cross-day PV vs deltaT for C7

T3(:,1) = (extractfield(XDay_PV_Summary.C57_7, 'Date1'))';
T3(:,2) = (extractfield(XDay_PV_Summary.C57_7, 'Date2'))';
T3 = datetime(T3,'InputFormat','yyyy-MM-dd');

for n = 1:size(T3,1)
    deltaT3(n,1) = daysact(T3(n,1),T3(n,2));
end

PV3 (:,1) = extractfield(XDay_PV_Summary.C57_7, 'Memory_Index');

%% get cross-day PV vs deltaT for C8

T4(:,1) = (extractfield(XDay_PV_Summary.C57_8, 'Date1'))';
T4(:,2) = (extractfield(XDay_PV_Summary.C57_8, 'Date2'))';
T4 = datetime(T4,'InputFormat','yyyy-MM-dd');

for n = 1:size(T4,1)
    deltaT4(n,1) = daysact(T4(n,1),T4(n,2));
end

PV4 (:,1) = extractfield(XDay_PV_Summary.C57_8, 'Memory_Index');

%% linear regression

T_WT = cat(1,deltaT1,deltaT2,deltaT3,deltaT4);
PV_WT = cat(1,PV1,PV2,PV3,PV4);

figure
F1 = fit(T_WT,PV_WT,'poly1');
plot(F1,T_WT,PV_WT,'ob');
xlabel('deltaT (days)')
ylabel('mean(PV correlation)')
set(gca, 'FontSize', 20)
ylim([-0.2,0.6])
xlim([0,53])
legend('off')
set(gca, 'Visible', 'off');

F11 = fitlm(T_WT,PV_WT);

%% AltPVnatively, exponential regression

figure
F2 = fit(T_WT,PV_WT,'exp1');
plot(F2,T_WT,PV_WT,'^b');
xlabel('deltaT (days)')
ylabel('mean(PV correlation)')
set(gca, 'FontSize', 20)
ylim([-0.2,0.6])
xlim([0,53])
legend('off')
set(gca, 'Visible', 'off');

end